<template lang="html">
  <div>
    <div class="search">
        <div class="input">
            <p>
				<label>工单状态:</label>
				<el-select placeholder="请输入内容" v-model="orderStatus">
						<el-option value="">请选择</el-option>
						<el-option
							v-for="(item,key) in orderList"
							:key="key"
							:label="item.label"
							:value="item.value"
						></el-option>
				</el-select>
			</p>
            <!-- <p><label>来源名称：</label><el-input placeholder="请输入编码" label="条件"></el-input></p>
            <p><label>来源编码：</label><el-input placeholder="请输入编码" label="条件"></el-input></p>
            <p><label>来源ID：</label><el-input placeholder="请输入编码" label="条件"></el-input></p> -->
            <p><el-button type="primary" class="se" @click="searchOrder()" style="margin-left:10px;">搜索</el-button></p>
        </div>
    </div>
    <!-- <div class="add">
       <el-button type="primary" @click="add">新增</el-button>
    </div> -->
    <tableVue :list="list" :state="false" @sizeChange="handleSize" :total="total" v-loading="loading">
        <slot>
          <el-table-column label="操作" align="center">
              <template slot-scope="scope">
                <el-button
                  size="mini"
                  @click="handleEdit(scope.row)">详情
                </el-button>
                <el-button
                  size="mini"
                  type="danger"
                  class="del"
                  @click="del(scope.row)">删除</el-button>
              </template>
          </el-table-column>
        </slot>
    </tableVue>
    <dialogVue title="新增工单信息" :dialog="dialog" @close="changeData" :state="false">
        <slot>
            <el-form :model="pageData" ref="ruleForm" label-width="120px" class="demo-ruleForm">
              <el-form-item label="评估师:">
                <el-select v-model="options.appraiserId" placeholder="请选择">
                    <el-option value="">请选择</el-option>
                    <el-option
                      v-for="(item,key) in appraiserList"
                      :key="key"
                      :label="item.empName"
                      :value="item.empId">
                    </el-option>
                  </el-select>
              	</el-form-item>
				<el-form-item label="订单:" prop="name">
					<el-input v-model="pageData.id" placeholder="请输入ID"></el-input>
				</el-form-item>
				<el-form-item label="派单时间:" prop="name">
					<el-input v-model="pageData.remark" placeholder="请输入备注"></el-input>
				</el-form-item>
				<el-form-item label="通知地址:" prop="name">
					<el-input v-model="pageData.remark" placeholder="请输入备注"></el-input>
				</el-form-item>
				<el-form-item class="confirm">
					<el-button type="primary" @click="submitForm('ruleForm')">创建</el-button>
				</el-form-item>
            </el-form>
        </slot>
    </dialogVue>
  </div>
</template>

<script>
import Data from './myorderData.js'
import dialogVue from '@/components/dialog.vue'
import tableVue from '@/components/alltable.vue'
import {
  appraiserAdminList,
  getAppraiserLists,
  delWorkOrder,
  getWorkOrderDetail
} from "@/api/appraiserAdmin/appraiserAdmin";
export default {
  components : {
    tableVue,
    dialogVue
  },
   data () {
		return JSON.parse(JSON.stringify(Data))
   },
   mounted () {

		this.getAppraiserAdminList({ 
			 current:1,
			 size:10
		 });
		this.getAppraiserList();
   },
   methods : {
     getAppraiserAdminList (data) {
       appraiserAdminList(data).then(res=>{
		   this.total = res.data.data.total;
		   this.loading =false;
           this.list.tbody = res.data.data.records.map(item=>{
			  switch(item.notifyResult){
				case "SUCCESS":
				  	item.notifyResult = "成功";
					break;
				case "FAILED":
					item.notifyResult = "失败";
					break;
				case "NOT_NOTIFY":
					item.notifyResult = "未通知";
					break;
				default:
					break;
			  }
               item.gmtCreate = this.switchTime(item.gmtCreate)
               item.gmtUpdate = this.switchTime(item.gmtUpdate)
               return item;
           });
       })
	 },
	 handleSize(size){
         console.log(size)
		  let data ={
			 workerOrderStatus:this.orderStatus,
			 current:size,
			 size:10
		 }
		 this.getAppraiserAdminList(data)
	 },
     changeData (data) {
       this.dialog = data;
     },
     add () { //新增工单
        this.dialog = true;
	 },
	 del(data){ //删除工单
	 	this.delMessage(()=>{
			 delWorkOrder(data.workOrderId).then(res=>{
				 console.log(res)
				 if(res.rows.code =="OK"){
					this.$message.success('删除成功');
					this.getAppraiserAdminList();
				 }else{
					this.$message.error(res.data.message);
				 }
			 })
		 })
	 },
	 handleEdit(data){
		 this.$router.push({path:'/appraiser/myorder/orderDetails',query:{id:data.workOrderId,key:'myOrder'}})
	 },
	 getAppraiserList(){ //获取评估师列表
		 getAppraiserLists().then(res=>{
			 if(res.data.code=="OK"){
				 this.appraiserList = res.data.data.records;
			 }else{
				 this.$message.error(res.data.code)
			 }
		 })
	 },
	 searchOrder(){
		 let data ={
			 workerOrderStatus:this.orderStatus
		 }
		 this.getAppraiserAdminList(data)
	 }
   }
}
</script>

<style scoped>
  @import "../../../styles/common.css";
</style>
